{extend name="../template/admin/head.html"}
{block name="title"}
页面管理_{__block__}
{/block}
{block name="content"}
<blockquote class="layui-elem-quote news_search">
    <div class="layui-inline">
      <a class="layui-btn layui-btn-normal newsAdd_btn" href="{:URL('Page/pageadd')}">添加新页面</a>
    </div>
    <div class="layui-inline">
      <div class="layui-form-mid layui-word-aux"> 说明：页面的修改与删除。</div>
    </div>
  </blockquote>
  <div class="layui-form news_list">
      <table class="layui-table">
        <colgroup>
        <col width="5%">
        <col width="10%">
        <col width="9%">
        <col width="9%">
        <col width="10%">
        </colgroup>
        <thead>
        <tr>
         <th><input type="checkbox" name="" lay-skin="primary" lay-filter="allChoose" id="allChoose"> 全选</th>
          <th style="text-align:left;">页面名称</th>
          <th>是否展示</th>
          <th>发布时间</th>
          <th>操作</th>
        </tr> 
        </thead>
        <tbody class="news_content">
  <colgroup>
    <col width="150">
    <col width="200">
    <col>
  </colgroup>
  <tbody>
{volist name='artice' id='artice'}
    <tr id="data{$artice.id}">
      <th><input type="checkbox" name="" lay-skin="primary" lay-filter="allChoose" id="allChoose"></th>
      <td>{$artice.title}</td>
      <td>
      <button class="layui-btn {if condition="($artice.show == 1)"}{else/}layui-btn-danger{/if}" title="点击修改状态" onclick="showstatus({$artice.id})">{if condition="($artice.show == 0)"}N{else/}Y{/if}</button>
      </td>
      <td>2016-11-29</td>
      <td><div class="layui-btn-group">
  <a href="{:URL('Page/pageedit')}?id={$artice.id}" class="layui-btn">编辑</a>
  <button class="layui-btn" onclick="delac({$artice.id})">删除</button>
</div></td>
    </tr>
{/volist}
  </tbody>
</div>
{/block}
{block name="jssrc"}
<script type="text/javascript">
  layui.use(['form', 'layedit', 'laydate'], function() {
    var form = layui.form,
    layer = layui.layer,
    layedit = layui.layedit,
    laydate = layui.laydate;

  });
  //删除文章数据
function delac(id){
layer.confirm('确认删除？', {
  btn: ['确认','取消'] //按钮
}, function(){
  if (id != "") {
        $.ajax({
          type:"POST",
          url:"{:URL('Artice/acdel')}",
          dataType:"json",
          data:{id:id},
          beforeSend: function () {
            // 动画显示
            layer.load(1);
            },
           error: function (XmlHttpRequest, textStatus, errorThrown) {
              if (XmlHttpRequest.responseText != "") {
                  layer.closeAll('loading');
                  layer.msg('提交失败，请稍后尝试！');
              }
          },
          success:function(data){
            //1为删除成功
            //2为删除失败
            if (data.result == "1") {
              layer.msg(data.msg);
              layer.closeAll('loading');
              $('#data'+id).remove();
            }else if(data.result = "2"){
              layer.closeAll('loading');
              layer.msg(data.msg);
            }
          }
        });
        return false;
    }else{
      layer.msg('ID值为空!');
      return false;
    }
});
}
//修改显示状态
function showstatus(id){
        $.ajax({
          type:"POST",
          url:"{:URL('Artice/showstatus')}",
          dataType:"json",
          data:{id:id},
          beforeSend: function () {
            // 加载动画
            layer.load(1);
            },
           error: function (XmlHttpRequest, textStatus, errorThrown) {
              if (XmlHttpRequest.responseText != "") {
                  layer.closeAll('loading');
                  layer.msg('提交失败，请稍后尝试！');
              }
          },
          success:function(data){
            //1为添加成功
            //2为添加失败
            if (data.result == "1") {
              layer.msg(data.msg);
              layer.closeAll('loading');
              setTimeout(function(){
                location.reload();
              },1000);
            }else if(data.result = "2"){
              layer.closeAll('loading');
              layer.msg(data.msg);
            }
          }
        });
}
</script>
{/block}